import { UserProfilesAPI } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: "",
            coin: 0,
            headImg: require("../../assets/img/service.848ec511.png")
        },
        cartTotal: 5
    },
    mutations: {
        changeUserInfo(state, payload) {
            state.userInfo = payload.userInfo
            state.cartTotal = payload.cartTotal
        },
        inituserInfo(state){
            state.userInfo = {
                //头像
                headImg: require("../../assets/img/userImg.f8bbec5e.png"),
                //昵称
                nickName: "--",
                //积分
                coin:"--"
            }
        }
    },
    actions: {
        async asyncChangeUserInfo({ commit }, payload) {
            let res = await UserProfilesAPI();
            commit('changeUserInfo',res.data)
        }
    }
}